import Vue from 'vue';
import Router from 'vue-router';

import Login from '@/views/login.vue';
import register from '@/views/register/index.vue';

import home from '@/views/home.vue';
import sliderPath from './silderPath.js';//导入silder路由

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      meta: {
        name: '登录',
      },
      component: Login,
    },
    {
      path: '/register',
      name: 'register',
      meta: {
        icon: '',
        name: '账号注册',
      },
      component: register,
    },
    {
      path: '/',
      name: 'home',
      meta: {
        name: '首页',
      },
      beforeEnter: (to, from, next) => {
        if (from.path != "/login") {
          alert("请登录");
          next({ name: 'login' })
        } else {
          next()
        }

      },
      component: home,
      children: sliderPath
    },
    {
      path: '*',
      redirect: '/404'
    }
  ]
})
